package com.xauto.pioneer.appuser.view;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.RelativeLayout;

import com.xauto.pioneer.appuser.R;

/***
 * image selector
 * @author Lemon Wed 1 Mar 14:02
 */
public class ImageSelectDialog extends Dialog {

    private Context mContext;
    ImageSelectCallBack imageSelectCallBack;
    public ImageSelectDialog(Context context,ImageSelectCallBack imgSelectCallBack) {
        super(context, R.style.LoadingDialogTheme);
        mContext = context;
        imageSelectCallBack = imgSelectCallBack;
        initView();
    }

    protected void initView() {
        setContentView(R.layout.dialog_image_select);
        getWindow().setGravity(Gravity.BOTTOM);
        getWindow().setLayout(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

        setCanceledOnTouchOutside(true);
        setCancelable(true);

        findViewById(R.id.textview_dialog_take_picture).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //拍照
                dismiss();
                imageSelectCallBack.takePhoto();
            }
        });
        findViewById(R.id.textview_dialog_album).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //相册选择
                dismiss();
                imageSelectCallBack.selectPhotos();
            }
        });
        findViewById(R.id.textview_dialog_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //取消
                dismiss();
            }
        });
    }

    public  interface ImageSelectCallBack{
        void takePhoto();
        void selectPhotos();
    }
}
